<?php

namespace zhtfrontend\models\datas;

use Yii;

/**
 * This is the model class for table "{{%settlement_relation}}".
 *
 * @property integer $settlement_id
 * @property integer $order_id
 * @property integer $order_sales_id
 */
class SettlementRelation extends \zhtfrontend\components\bases\BaseModel
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return '{{%settlement_relation}}';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['settlement_id', 'order_id', 'order_sales_id'], 'required'],
            [['settlement_id', 'order_id', 'order_sales_id'], 'integer']
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'settlement_id' => Yii::t('zhtfrontend', '结算编号'),
            'order_id' => Yii::t('zhtfrontend', '订单编号\''),
            'order_sales_id' => Yii::t('zhtfrontend', '订单商品编号'),
        ];
    }


    public function getOrder()
    {
        return $this->hasOne(Orders::className(), ['id' => 'order_id']);
    }


    public function getOrderSales()
    {
        return $this->hasOne(OrdersItems::className(), ['id' => 'order_sales_id']);
    }

    public function getSettlement()
    {
        return $this->hasOne(Settlement::className(), ['settlement_id' => 'settlement_id']);
    }
}
